package com.sopt.eat;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;

import android.widget.Spinner;

public class MainActivity extends Activity implements OnClickListener {
	private Button goToMapButton;
	private Button goToHistoryButton;
	private Spinner s;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		goToMapButton = (Button) findViewById(R.id.goToMap);
		goToHistoryButton = (Button) findViewById(R.id.goToHistory);
		
		goToMapButton.setOnClickListener(this);
		goToHistoryButton.setOnClickListener(this);
		
		s = (Spinner) findViewById(R.id.spinner);
		ArrayAdapter<?> adapter = ArrayAdapter.createFromResource(this,
				R.array.categorys, android.R.layout.simple_spinner_item);
		adapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		s.setAdapter(adapter);

	}

	public void onClick(View v) {
		if (v == goToMapButton) {

			Intent mapIntent = new Intent(MainActivity.this,
					EatMapActivity.class);

			mapIntent.putExtra("currentCategory", s.getSelectedItem().toString());

			startActivity(mapIntent);
		} else if(v == goToHistoryButton){
			startActivity(new Intent(this,HistoryActivity.class));
		}
	}

}